1. Field of the Invention
The present invention relates to printer drivers and methods of communication between a computer and a printer in a computer graphics system. More particularly, the present invention relates to printer drivers that perform graphic operations using a set of graphics primitives.
2. State of the Art
The relative complexity of rendering a graphical image, whether on a computer display or on a printed page, has resulted in the development of a number of different graphical "languages". Some of these languages, for example Printer Control Language (PCL), are primarily applicable to producing hard copy. Other "page description" languages are applicable to both displaying images on a computer screen and printing images on print media. For example, in a Macintosh computer, a graphics library known as "QuickDraw", part of the Macintosh Operating System, may be used to produce images on screen or off screen. Similarly, in PC-compatible computers, the Windows operating system provides drawing routines in the form of a Graphics Device Interface library which is used for imaging all complex graphic operations either on or off screen. For purposes of describing the present invention, reference will be made to QuickDraw; it should be understood, however, that the invention is and will be applicable to a wide variety of graphical languages.
Referring to FIG. 1, QuickDraw converts graphics commands from a higher-level application program 101 for presentation on a video screen or for printing on print media. QuickDraw provides a graphics library built into every Macintosh computer, and is described more fully in "Inside Macintosh, Vol. 1, by Apple Computer, Inc., which is incorporated herein by reference. Besides being used to draw most of the contents of the computer screen, QuickDraw may be used for communicating with a computer printer. QuickDraw routines stored in the computer's read-only memory (ROM) may therefore constitute a core, which, together with certain printer-dependent control functions, forms a printer driver 300 responsive to commands from an application program to cause a printer 107 to print a desired image from memory 105 onto a page.
QuickDraw defines some clear mathematical constructs that are widely used in its procedures, functions and data types. The most basic QuickDraw type is the point which consists of two integers for specifying a horizontal and vertical position in a coordinate plane. Other types are lines, rectangles, ovals, arcs, rounded-corner rectangles, polygons, and regions. Many drawing operations consist of filling or framing these objects with a pattern. QuickDraw also supports drawing text in multiple fonts in various sizes and styles. QuickDraw draws by altering a bit image in an area of memory, the frame buffer in the case of screen display and the print buffer in the case of printed output.
QuickDraw allows a number of separate drawing areas called GrafPorts to be defined. Each GrafPort has its own complete drawing environment that defines how and where graphic operations will have their effect. Many GrafPorts can be open at once and each one will have its own coordinate system, drawing pattern, background pattern, pen size and location, character font and style, etc. GrafPorts are fundamental to the Macintosh's overlapping window user interface. One GrafPort may be designated as the printer GrafPort in order to draw a page for printing.
Each GrafPort has a rectangle, called the portRect, which defines the area for use by the GrafPort. Each GrafPort also has its own clipping region which can be used to further limit drawing to any subset of the GrafPorts's portRect. Each GrafPort has a drawing pen which is used for drawing lines, shapes, and text. The pen has four characteristics: a location, a size, a drawing mode, and a drawing pattern. The pen mode and pen pattern determine how the bits "under" the pen are affected as the pen "moves over" them when drawing lines and shapes. Each GrafPort also has its own text font, style, mode and size for drawing text within the GrafPort.
There are five different drawing operations for drawing different image shapes, namely, frame, paint, erase, invert and fill. Each of the shape-drawing operations can be applied to rectangles, regions, ovals arcs, rounded-corner rectangles and polygons. In addition, QuickDraw provides routines to draw text and to perform bit-copy operations.
For each shape that QuickDraw can produce, there are separate procedures that perform the basic graphic operations to produce that shape: frame, paint, erase, invert and fill. Each of these procedures in turn calls a low-level internal QuickDraw routine for the shape to actually perform the drawing. For example, The FrameOval, PaintOval, EraseOval, InvertOval and FillOval procedures in QuickDraw actually call a single low-level routine within QuickDraw which performs these operations on ovals. There are also low-level procedures for drawing text, lines, and for performing bitcopy operations. Low-level routines are also called bottleneck procedures, which may be regarded as graphics primitives. The main QuickDraw bottleneck procedures are: StdText, StdLine, StdBits, StdRect, StdRRect, StdOval, StdPoly and StdRgn.
In order to image a page, a QuickDraw printer driver operates first in a capture mode of operation, then in a playback mode of operation. During capture, typically, GrafPort setting changes and commands to draw various shapes are received. Information reflecting these changes is saved in a stream, for example to a disk file. When a Close Page command is received, the printer driver causes the application program to wait. The printer driver then plays back the shapes and GrafPort changes that describe the page and manipulates bits in the print buffer accordingly to render an image of the page. Because of the memory-intensive nature of graphics information, the page is typically imaged in a succession of bands.
Most QuickDraw print drivers use a "DrawPicture" methodology to print. This method requires each and every GrafPort change to be recorded and played back for each band. As a result, the number of disk accesses and the amount of disk storage required to print a typical print job becomes large. Because of disk latency, printing time is prolonged.
One solution has been to, instead of recording each and every change to printer GrafPort in the order in which it occurs, recording to stream a "snapshot" of the GrafPort state at the time a command to draw a shape is received (if the GrafPort state has changed since it was last recorded). The shape is then stored to stream with a reference to the GrafPort state. Additionally, information denoting a bounding rectangle of the shape is stored with the shape. When the printer driver renders an imaging band, it can then send a bounding rectangle of the band to a stream manager, requesting playback of only those shapes whose bounding rectangles intersect with the imaging band.
In this improved arrangement then, the printer driver stores in essence a condensed picture of the GrafPort fields in a "State" object at the time each shape is drawn by the application. As shapes are rendered in the imaging bands, only the specific State necessary for drawing is required to be read back, not the sequence of every change to the GrafPort.
Such an arrangement nevertheless uses a relatively large amount of data to save States. In particular, storing pen patterns and fill patterns in each State results in a large amount of data being stored and retrieved.
What is needed, then, is a method whereby graphic images may be produced using fewer disk accesses and less disk space (especially as compared with the DrawPicture methodology) without reducing the ability to recreate the exact drawing environment specified by a drawing application.